<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>addBuildApply</title>
    <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" media="all" href="/css/common.css"/>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/myJs.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="/css/CaseManager.css"/>
</head>
<body>
<div>
    <br/><br/><br/>
    <div class="layui-inline">
        <input class="layui-btn  layui-btn-primary"  style="width: 600px ;border:0" type="button" value="服务管理" onclick="one()" />
        <input class="layui-btn layui-btn-primary" style="width: 600px;border:0" type="button" value="服务状态" onclick="tow()"/>
        <input class="layui-btn  layui-btn-warm" style="width: 600px;border:0" type="button" value="部署申请" />
    </div>
    <br/><br/><br/>
</div>
<div class="layui-container">
    <!--6/12 布局-->
    <div class="layui-row">

        <div class="layui-col-xs-offset3">

            <form id="addBuildForm" class="layui-form layui-form-pane">

                <br/>
                <br/>
                <br/>

                <div class="layui-form-item">
                    <label class="layui-form-label ">环境选择:</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <datalist id="buildEnv">
                            <option label="sit" value="sit" />
                            <option label="beta" value="beta" />
                            <option label="uat" value="uat" />
                        </datalist>
                        <input type="text" list="buildEnv" placeholder="" name="vDev" autocomplete="off" class="layui-input"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label ">服务类型:</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <datalist id="serverType">
                            <option label="后台服务" value="后台服务" />
                            <option label="web服务" value="web服务" />
                            <option label="App服务" value="App服务" />
                            <option label="脚本跑批" value="脚本跑批" />
                        </datalist>
                        <input type="text" list="serverType" placeholder="" name="serverType" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <!--服务名称-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">服务名</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="vServerName" required="required" autocomplete="off" placeholder="" class="layui-input" />
                    </div>
                </div>
                <!--版本号-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">版本号</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="vVersion" required="required" autocomplete="off" placeholder="后台需填" class="layui-input" />
                    </div>
                </div>
                <!--分支-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">前端分支:</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <datalist id="vBranch">
                            <option label="origin/dev-season" value="origin/dev-season" />
                            <option label="origin/beta" value="origin/beta" />
                        </datalist>
                        <input type="text" list="vBranch" placeholder="" name="vBranch" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <!--申请人-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">申请人</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="vLeader" autocomplete="off" placeholder="" class="layui-input" />
                    </div>
                </div>
                <br/>
                    <button type="reset" style="width: 410px" class="layui-btn layui-btn-warm" lay-filter="add" id="buildApplyBt" lay-submit="">提交</button>
            </form>
        </div>
    </div>
</div>
<div class="fly-footer">
    <p><a target="_blank">我打 - 服务管理系统</a> 2018</p>
</div>
<script>
    function back(){
        loadPage("/server/baseServer")
    }
    function loadPage(url) {
        window.location.href = url;
    }
    function serializeObject(form){
        var o ={};
        $.each(form.serializeArray(),function(index){
            if(o[this['name']]){
                o[this['name']] = o[this['name']] +","+this['value'];

            }else{
                o[this['name']] = this['value'];
            }
        });
        return o;
    }
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.render();
        //监听提交
        form.on('submit(add)', function(data){

            var from= $("#addBuildForm");
            var model= serializeObject(from);

            $.ajax({
                type: "post",
                url: "/server/addBuildForm",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(model),
                dataType: "json",
                success: function(data) {
                    layer.confirm('新建成功', function(index){
                        loadPage("/server/buildApply");
                    });
                }
            })
        });
    });
</script>
<script>
    function one(){
        loadPage("/server/baseServer")
    }
    function tow(){
        loadPage("/server/buildRecord")
    }
    function three(){
        loadPage("/server/buildAuditList")
    }
</script>
</body>
</html>